import argparse
from rammer import Rammer


# Define the main function to handle PDF text extraction and reformatting
def main():
    # Set up the command-line argument parser
    parser = argparse.ArgumentParser(
        description="PDF to PDF text extraction and reformatting."
    )
    # Define the required input PDF file path argument
    parser.add_argument("input_pdf", help="Input PDF file path")
    # Define the optional font path argument with a default value
    parser.add_argument(
        "--font_path", default="fonts/Senkita.ttf", help="Path to the font file"
    )
    # Define the optional font size argument with a default value
    parser.add_argument(
        "--font_size", type=int, default=10, help="Font size for the output PDF"
    )
    # Parse the command-line arguments
    args = parser.parse_args()

    try:
        # Instantiate the Rammer class with the provided arguments and reformat the PDF
        Rammer(args.input_pdf, args.font_path, args.font_size).reformat_pdf()

        # Print a success message if the conversion is completed without errors
        print("Conversion completed successfully.")
    except Exception as e:
        # Print an error message if an exception occurs during the conversion process
        print(f"Error during conversion: {e}")


if __name__ == "__main__":
    # Call the main function if the script is executed directly
    main()